import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  //代理
  server: {
    proxy: {
      '/fetch': {
        target: "http://localhost:3001",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/fetch/, '')
      },
      '/amap': {
        target: 'https://restapi.amap.com',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/amap/, '')
      }
    },
    // host: "192.168.3.69", // ip启动服务
    port: 3001, // 将端口更改为 3001
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  plugins: [vue()],
  css: {
    // CSS 预处理器
    preprocessorOptions: {
      //define global scss variable
      scss: {
        javascriptEnabled: true,
        additionalData: `
          @use "@/assets/css/design.scss" as *;
        `,
      },
    },
  },
  build: {
    // 确保静态资源路径正确
    outDir: 'dist',
    assetsDir: 'screen_assets'
  }
})
